import Vue from "vue";
import Router from "vue-router";

Vue.use(Router);

function loadView(view) {
    // which is lazy-loaded when the route is visited.
    return () => import(`@/components/${view}.vue`);
}
// function returnModule() {
//     var substrModuleString = location.href.substring( 7,  location.href.length );
//     var moduleString = substrModuleString.split('/');
//     return moduleString[1];
// }
export default new Router({
    mode: "history",
    linkExactActiveClass: "showActive",
    base: process.env.BASE_URL,
    scrollBehavior(to, from, savedPosition) {
        return {
            x: 0,
            y: 0
        }
    },
    routes: [{
            path: "/login",
            name: "login",
            authName: "login",
            whileRoute: true,
            txtName: "登录",
            component: loadView("common/login")
        },
        // {
        //     path: "/register",
        //     name: "register",
        //     authName: "register",
        //     txtName: "注册",
        //     component: loadView("register/index")
        // },
        //教师培训
        /*       {
                   path: "/train",
                   name: "train",
                   authName: "train",
                   txtName: "教师培训-首页",
                   component: loadView("train/base/main"),
                   children: [
                       {
                           path: "index",
                           name: "index",
                           authName: "index",
                           txtName: "教师培训",
                           component: loadView("train/index/index")
                       },
                       {
                           path: "manage",
                           name: "manage",
                           authName: "manage",
                           txtName: "培训管理",
                           component: loadView("train/index/train-list"),
                           children: [
                               {
                                   path: "index",
                                   name: "index",
                                   authName: "index",
                                   txtName: "教师培训",
                                   component: loadView("train/index/train-teacher")
                               },
                               {
                                   path: "partake",
                                   name: "partake",
                                   authName: "partake",
                                   txtName: "批卷阅卷",
                                   component: loadView("train/index/train-partake")
                               }
                           ]
                       },
                       {
                           path: "teacher-add",
                           name: "teacher-add",
                           authName: "teacher-add",
                           txtName: "新增培训",
                           component: loadView("train/index/train-teacher-add")
                       },
                       {
                           path: "teacher-edit",
                           name: "teacher-edit",
                           authName: "teacher-edit",
                           txtName: "培训列表 > 培训管理 >编辑培训",
                           component: loadView("train/index/train-teacher-edit")
                       },
                       {
                           path: "teacher-detail",
                           name: "teacher-detail",
                           authName: "teacher-detail",
                           txtName: "培训列表 > 培训管理 >编辑培训",
                           component: loadView("train/index/train-teacher-detail")
                       },
                       {
                           path: "file",
                           name: "file",
                           authName: "file",
                           txtName: "培训列表 > XXX培训>  这是文档名称",
                           component: loadView("train/index/train-file")
                       },
                       {
                           path: "video",
                           name: "video",
                           authName: "video",
                           txtName: "培训列表 > XXX培训>  这是文档名称",
                           component: loadView("train/index/train-video")
                       },
                       {
                           path: "statistics",
                           name: "statistics",
                           authName: "statistics",
                           txtName: "培训列表 > 培训管理 > 统计",
                           component: loadView("train/index/train-teacher-statistics")
                       },
                       {
                           path: "review",
                           name: "review",
                           authName: "review",
                           txtName: "培训列表 > 培训管理 > 批阅",
                           component: loadView("train/index/train-teacher-review")
                       },
                       {
                           path: "paper",
                           name: "paper",
                           authName: "paper",
                           txtName: "培训列表 > 培训管理 > 作答试卷",
                           component: loadView("train/index/train-test-paper")
                       },
                       {
                           path: "test-detail",
                           name: "test-detail",
                           authName: "test-detail",
                           txtName: "培训列表 > 培训管理 > 作答试卷",
                           component: loadView("train/index/train-test-detail")
                       },
                       {
                           path: "test-review",
                           name: "test-review",
                           authName: "test-review",
                           txtName: "培训列表 > 培训管理 > 批阅 > xxx的答题试卷批阅",
                           component: loadView("train/index/train-test-review")
                       },
                       {
                           path: "test-see",
                           name: "test-see",
                           authName: "test-see",
                           txtName: "培训列表 > 培训管理 > 批阅 > xxx的答题试卷查看",
                           component: loadView("train/index/train-test-see")
                       },
                       {
                           path: "batch",
                           name: "batch",
                           authName: "batch",
                           txtName: "批卷阅卷",
                           component: loadView("train/index/train-list"),
                           children: [
                               {
                                   path: "index",
                                   name: "index",
                                   authName: "index",
                                   txtName: "批卷阅卷",
                                   component: loadView("train/index/train-batch")
                               }
                           ]
                       }
                   ]
               },
               //排课评课
               {
                   path: "/course",
                   name: "course",
                   authName: "course",
                   txtName: "排课评课",
                   component: loadView("course/base/main"),
                   children: [
                       {
                           path: "",
                           name: "list",
                           authName: "list",
                           txtName: "列表",
                           component: loadView("course/index/list")
                       },
                       {
                           path: "reservation",
                           name: "reservation",
                           authName: "reservation",
                           txtName: "我的预约",
                           component: loadView("course/index/my-reservation")
                       },
                       {
                           path: "add",
                           name: "add",
                           authName: "add",
                           txtName: "新建预约",
                           component: loadView("course/index/my-reservation-add")
                       },
                       {
                           path: "edit",
                           name: "edit",
                           authName: "edit",
                           txtName: "预约编辑",
                           component: loadView("course/index/my-reservation-edit")
                       },
                       {
                           path: "entry",
                           name: "entry",
                           authName: "entry",
                           txtName: "录入课前资料",
                           component: loadView("course/index/my-reservation-entry")
                       },
                       {
                           path: "reflect",
                           name: "reflect",
                           authName: "reflect",
                           txtName: "教学反思",
                           component: loadView("course/index/reflect")
                       },
                       {
                           path: "reflect-add",
                           name: "reflect-add",
                           authName: "reflect-add",
                           txtName: "录入反思",
                           component: loadView("course/index/reflect-add")
                       },
                       {
                           path: "reflect-edit",
                           name: "reflect-edit",
                           authName: "reflect-edit",
                           txtName: "录入反思",
                           component: loadView("course/index/reflect-edit")
                       },
                       {
                           path: "excellent",
                           name: "excellent",
                           authName: "excellent",
                           txtName: "精品课程",
                           component: loadView("course/index/excellent-course")
                       },
                       {
                           path: "video",
                           name: "video",
                           authName: "video",
                           txtName: "精品课程",
                           component: loadView("course/index/video")
                       },
                       {
                           path: "class",
                           name: "class",
                           authName: "class",
                           txtName: "公开课评级",
                           component: loadView("course/index/class")
                       },
                       {
                           path: "class-list",
                           name: "class-list",
                           authName: "class-list",
                           txtName: "评级列表",
                           component: loadView("course/index/class-list")
                       },
                       {
                           path: "class-list-add",
                           name: "add",
                           authName: "add",
                           txtName: "新增评级列表",
                           component: loadView("course/index/class-list-add")
                       },
                       {
                           path: "class-list-edit",
                           name: "edit",
                           authName: "edit",
                           txtName: "编辑评级列表",
                           component: loadView("course/index/class-list-edit")
                       },
                       {
                           path: "live",
                           name: "live",
                           authName: "live",
                           txtName: "直播",
                           component: loadView("course/index/live")
                       }
                   ]
               },
               // 圈组
               {
                   path: "/group",
                   name: "group",
                   authName: "group",
                   txtName: "圈组首页",
                   component: loadView("group/base/main"),
                   children: [
                       {
                           path: "",
                           name: "index",
                           authName: "index",
                           txtName: "圈组列表页",
                           component: loadView("group/index/group-list")
                       },
                       {
                           path: "introduct",
                           name: "introduct",
                           authName: "introduct",
                           txtName: "圈组介绍",
                           component: loadView("group/index/group-introduction"),
                           children:[
                               {
                                   path: "discuss",
                                   name: "discuss",
                                   authName: "discuss",
                                   txtName: "圈组讨论",
                                   component: loadView("group/index/group-discuss")
                               },
                           ]
                       },
                       {
                           path: "manage",
                           name: "manage",
                           authName: "manage",
                           txtName: "圈组管理",
                           component: loadView("group/index/group-manage"),
                           children: [
                               {
                                   path: "selfCreated",
                                   name: "selfCreated",
                                   authName: "selfCreated",
                                   txtName: "我创建的圈组",
                                   component: loadView("group/index/group-selfCreated")
                               },
                               {
                                   path: "approval",
                                   name: "approval",
                                   authName: "approval",
                                   txtName: "成员审批",
                                   component: loadView(
                                       "group/index/group-member-approval"
                                   )
                               },
                               {
                                   path: "iJoin",
                                   name: "iJoin",
                                   authName: "iJoin",
                                   txtName: "我加入的圈组",
                                   component: loadView("group/index/group-i-join")
                               },
                               {
                                   path: "inviteMe",
                                   name: "inviteMe",
                                   authName: "inviteMe",
                                   txtName: "邀请我的圈组",
                                   component: loadView("group/index/group-invite-me")
                               }
                           ]
                       },
                       {
                           path: "manageOne",
                           name: "manageOne",
                           authName: "manageOne",
                           txtName: "管理一个圈组",
                           component: loadView("group/index/group-manage-one")
                       },
                       {
                           path: "groupAdd",
                           name: "groupAdd",
                           authName: "groupAdd",
                           txtName: "创建圈组",
                           component: loadView("group/index/group-add")
                       }
                   ]
               },
               //名师中心
               {
                   path: "/terch",
                   name: "terch",
                   authName: "terch",
                   txtName: "名师中心-首页",
                   component: loadView("terch/base/main"),
                   children: [
                       {
                           path: "/",
                           name: "home",
                           authName: "home",
                           txtName: "名师中心-首页",
                           component: loadView("terch/index/index"),
                       },
                       {
                           path: 'space',
                           name: 'space',
                           authName: 'space',
                           txtName: '名师-个人空间',
                           component: loadView('terch/index/space'),
                           children:[
                               {
                                  path: '',
                                  name: 'video',
                                  authName: 'video',
                                  txtName: '视频',
                                  component: loadView('terch/index/video'), 
                               },
                               {
                                    path: 'resource',
                                    name: 'resource',
                                    authName: 'resource',
                                    txtName: '教学资源',
                                    component: loadView('terch/index/resource'), 
                               },
                               {
                                  path: 'journal',
                                  name: 'journal',
                                  authName: 'journal',
                                  txtName: '视频',
                                  component: loadView('terch/index/journal'), 
                               },
                               {
                                   path:'fans',
                                   name: 'fans',
                                   authName: 'fans',
                                   txtName: '粉丝',
                                    component: loadView('terch/index/fans'), 
                               },
                               {
                                   path:'follow',
                                   name: 'follow',
                                   authName: 'follow',
                                   txtName: '关注',
                                    component: loadView('terch/index/follow'), 
                               }
                           ]
                       },
                       {
                           path: "see",
                           name: "ee",
                           authName: "see",
                           txtName: "名师中心-首页",
                           component: loadView("terch/index/journal-detail"),
                       },
                   ]
               }*/
    ]
});